package com.shop.cereshop.agent.param.user;

import com.shop.cereshop.commons.config.RsaProperties;
import com.shop.cereshop.commons.utils.RsaUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

    /**
     * 获取验证码请求实体
     */
    @Data
    @ApiModel(value = "GetCodeParam", description = "获取验证码参数实体")
    @Slf4j
    public class BuyerGetCodeDTO {
        /**
         * 电话
         */
        @ApiModelProperty(value = "电话", required = true)
        private String phone;


        public BuyerGetCodeDTO decrypt() throws Exception {
            BuyerGetCodeDTO res = this;
            try {
                res.setPhone(RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, this.phone));
            } catch (Exception e) {
                log.error("解密失败");
            }
            return res;
        }
    }
